package com.action;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.dao.BaseDAO;
import com.entity.Kuaijian;
import com.entity.Room;
import com.entity.Stu;
import com.entity.Userinfo;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class KuaiJianAction extends ActionSupport {
	Kuaijian data;

	BaseDAO dao = new BaseDAO();

	public String add() {
		data.setCurtime(new Date());
		dao.add(data);
		return show();
	}

	public String del() {
		dao.del(dao.findByID(Kuaijian.class, data.getId()));
		return show();
	}

	public String push() {
		Kuaijian info = (Kuaijian)dao.findByID(Kuaijian.class, data.getId());
		info.setStatus(2);
		dao.update(info);
		return show();
	}
	
	public String change() {
		Kuaijian info = (Kuaijian)dao.findByID(Kuaijian.class, data.getId());
		info.setStatus(2);
		dao.update(info);
		return show();
	}
	public String show() {
		ActionContext.getContext().put("all", dao.show("from Kuaijian"));
		return SUCCESS;
	}
	
	
	public String find() {
		String hql = "from Kuaijian where 1=1";
		List params = new ArrayList();
		
		
		if(!"".equals(data.getStuno())){
			hql+=" and stuno=?";
			params.add(data.getStuno());
		}
		
		ActionContext.getContext().put("all", dao.find(hql, params.toArray()));
		return "kuai";
	}
	
	
	

	public Kuaijian getData() {
		return data;
	}

	public void setData(Kuaijian data) {
		this.data = data;
	}
}
